import csv
from random import choice

def load_csv(filename:str, header=None) -> tuple:
    """读取csv中的数据

    Args:
        filename (str): csv文件名
        header (list, optional): 指定读取数据的表头. 默认为None, CSV文件的第一行作为表头.

    Returns:
        Tuple[list]: (表头, 二维数据列表)
    """
    data = []
    with open(filename, "r", encoding="utf-8") as fp:
        reader = csv.reader(fp)
        header =  header if header else next(reader)
        for line in reader:
            data.append([int(n) for n in line])
    return header, data

def load_txt(filename:str) -> list:
    data = []
    with open(filename, "r", encoding="utf-8") as fp:
        while line := fp.readline().strip():
            data.append(line)
    
    return data

